<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/vue.js"></script>
</head>
<body>
    <div id="app">
        <div>在文本框中不断输入字符，然后按下enter之后，展示已经输入的字符，并且清空文本框</div>
        {{msg}}
        <input type="text" v-on:keydown="keydown">
    </div>
    <script>
        var vm = new Vue({
            el: '#app',
            data: {
                msg: ''
            },
            methods: {
                keydown(e){
                    console.log(e.keyCode);
                    if(e.keyCode == 13){
                        this.msg = e.target.value;
                        e.target.value="";
                    }
                }
            }
        })
    </script>
</body>
</html>